package com.xdcplus.web.controller.report;

import com.xdcplus.exceptions.domain.ResponseVO;
import com.xdcplus.mom.controller.AbstractController;
import com.xdcplus.mom.pojo.vo.DeviceFixRecordVO;
import com.xdcplus.mom.pojo.vo.DevicePmRecordVO;
import com.xdcplus.mom.pojo.dto.EpmStatusBoardDataFilterDTO;
import com.xdcplus.web.service.report.EpmStatusBoardDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Zhecheng.Ren
 * @since 2024/9/30 11:17
 */
@Api(tags = "EPM设备状态数据查询API")
@Slf4j
@Validated
@RestController
@AllArgsConstructor
@RequestMapping("api/epmBoardData")
public class EpmStatusBoardDataController extends AbstractController {

    @Resource
    private EpmStatusBoardDataService epmStatusBoardDataService;

    @ApiOperation("查询EPM 保养记录")
    @PostMapping(value = "/pm", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseVO<List<DevicePmRecordVO>> queryPmBoardData(@RequestBody EpmStatusBoardDataFilterDTO epmStatusBoardDataFilterDTO) {
        return ResponseVO.success(epmStatusBoardDataService.queryPmRecord(epmStatusBoardDataFilterDTO.getStartDate(), epmStatusBoardDataFilterDTO.getEndDate()));
    }

    @ApiOperation("查询EPM 维修记录")
    @PostMapping(value = "/fix", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseVO<List<DeviceFixRecordVO>> test(@RequestBody EpmStatusBoardDataFilterDTO epmStatusBoardDataFilterDTO) {
        return ResponseVO.success(epmStatusBoardDataService.queryFixRecord(epmStatusBoardDataFilterDTO.getStartDate(), epmStatusBoardDataFilterDTO.getEndDate()));
    }

}
